class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2025-08-12",
      revision: "78c8c365973234f9a73c20b8c8cdcfc4dfa5cb2a"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_sequoia: "54f067db5b30bb4dafd63fae0e5eb0fb98cd918ccc1dc854539278488ffa380a"
    sha256 cellar: :any_skip_relocation, arm64_sonoma:  "ba4b2c3ba5d9ac77a121eebeb8c69fabbe681be6ed5a306033d10dc4e87a6e60"
    sha256 cellar: :any_skip_relocation, arm64_ventura: "2537baaee5013564949a7ad253039e65aa693a9a261319318767dd6d55497be3"
    sha256 cellar: :any_skip_relocation, sonoma:        "d1efd61ca84926f329527e9edf4bc8cf60deebafed2305d52adc386fcbb7e643"
    sha256 cellar: :any_skip_relocation, ventura:       "5a30c592680bceed864f29f6bb47dbbd954223793a5093df82abf9aa884326fd"
    sha256 cellar: :any_skip_relocation, arm64_linux:   "216feb3392ccd10e3d84cfc69aa282dbb4d5f81eb6a67738570682af8c6c5e29"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "27b356e712591dce64c77f424359d333021ee50a3382472dc90bf240488b82c7"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system bin/"searchsploit", "sendpage"
  end
end
